<form method="post" action="<?php echo $this->baseUrl("/pcjobs/manage/update/{$id}") ?>">
<?php /* View Job Information */ ?>
<?php if($action=='view'):?>
<?php
if(App::getUserStatusId())
{
    App::Helper('Toolbar')->setTitle("View Job")->setBtnBack()->Render(array('code'=>'job_view_top'));
}
else
{
     App::Helper('Toolbar')->setTitle("View Job")->setBtnBack()->Render(array('code'=>'pcjob_view_top'));
}

?>

	<?php if(isset($id)):?>
		<?php
			$EndDateData = App::Component('Photocliping')->helper('Data')->calculateEndDate($Data);
           // pre($EndDateData);
			$enddate = "-";
			if(!empty($EndDateData))
			{
				$enddate = $EndDateData['enddate'];
				$color = $EndDateData['legend'][0];
				$sp = "{$EndDateData['legend'][1]}";
			}

			/*if(isset($ed['enddate']) && $ed['enddate'] != "")
			{
				$enddate = $ed['enddate'];
			}
			else if() ? "Time over by {$ed['legend'][1]}": $ed['enddate'];*/

         $member = App::MemberManager()->Members($Data['client_id']);
		 App::Module('DataGrid')->clear()
			->setDisplay('FormListing')
            ->addRow("Client",App::Helper('Html')->linkTag($this->baseUrl("/member/manage/view/{$member['id']}"),$member['name']))
			->addRow("Title",$Data['title'])
			->addRow("Service",App::CategorySet()->idToName($Data['service_id']));
//pre($Data);
		 App::Module('DataGrid')->addRow("Total Image",$Data['num_images']);

		 App::Module('DataGrid')->addRow("Description",(($Data['description']!="")?$Data['description']:"-"))
			->addRow("Delivery Type",App::CategorySet()->idToName($Data['delivery_type']))
			->addRow("Delivery Time	",App::CategorySet()->idToName($Data['delivery_time']))
			->addRow("Discount",$Data['discount'])
			->addRow("Created",App::Load("Helper/Date")->dateFormated($Data['created'],'long'))
			->addRow("Start Date",(($Data['start_date']!="")?App::Load("Helper/Date")->dateFormated($Data['start_date'],'long'):"&nbsp;"))
			->addRow("End Date",$enddate)
			->addRow("Status",App::Component('Photocliping')->Helper("Data")->statusBox($Data['status']));
		if($Data['downloadtype'] == 'Ftp')
		{
			App::Module('DataGrid')->addRow("Ftp Loc",$Data['ftp_loc']);
            if(App::getUserStatusId())
            {
			    App::Module('DataGrid')->addRow("Total Price($)",$Data['total']);
            }
            else
            {
                 App::Module('DataGrid')->addRow("Total Price($)",App::Helper('Html')->inputTag("data[Job][total]",$Data['total']));
            }
			App::Module('DataGrid')->addRow("Comments",(($Data['comments']!="")?$Data['comments']:"-"));
		}
		else
		{
			App::Module('DataGrid')->addRow("Total($)",$Data['total']);
		}
         
         $paymentstatus = App::Component('Photocliping')->Helper("Data")->paymentStatus($Data['paymentstatus']);

        if(App::getUserStatusId())
        {
		 App::Module('DataGrid')->addRow("Download Link",App::Component('Photocliping')->Helper("Data")->downloadBox($Data['download_link']))
			->addRow("Payment Status",$paymentstatus)
			->Render();
        }
        else
        {
           // pr($paymentstatus);
		 App::Module('DataGrid')->addRow("Download Link",App::Component('Photocliping')->Helper("Data")->downloadBox($Data['download_link']))
			->addRow("Payment Status",App::Helper('Html')->selectTag("data[Job][paymentstatus]",Array("NotPaid"=>"NotPaid","Paid"=>"Paid"),$paymentstatus))
			->Render();
        }


		?>
		<?php if($Data['downloadtype'] == 'File'):?>
		<h3>File Information</h3>
		<?php
		 $Files = App::Component('Photocliping')->Helper('Data')->allFilesById($Data['id']);
		 App::Module('DataGrid')->clear()
			->setDisplay('TableListing')
			->setHeader(Array("ID","Name","Created","Rate",""))
			->setFooter($Files['paging_str']);
			foreach($Files['data'] as $File)
			{
				 App::Module('DataGrid')->addRow
				 ($File['id'],$File['name'],App::Load("Helper/Date")->dateFormated($File['created'],'long'),App::Component('Photocliping')->Helper("Data")->rateBox($File),App::Helper('Html')->imgDTag($this->baseDir("/uploads/photo/{$Data['token']}/{$File['name']}"),"/40/fix"));
			}
		App::Module('DataGrid')->Render();
		?>
		<?php endif;?>
	<?php else:?>
		<div class="sales">
			<div class="legend">
				<h6>Legend</h6>
				<ul>
					<li style="border-left:12px solid <?php echo Component_Photocliping_Helpers_Data::COLOR_TIME12;?>">1/2 Time</li>
					<li style="border-left:12px solid <?php echo Component_Photocliping_Helpers_Data::COLOR_TIME14;?>">1/4 Time</li>
					<li style="border-left:12px solid <?php echo Component_Photocliping_Helpers_Data::COLOR_NOTCOMPLETE;?>">NOT completed but time over</li>
					<li style="border-left:12px solid <?php echo Component_Photocliping_Helpers_Data::COLOR_TIMEXTRA;?>">Completed but with extra time</li>
					<li style="border-left:12px solid <?php echo Component_Photocliping_Helpers_Data::COLOR_TIMEON;?>">Completed within time</li>
				</ul>
			</div>
			<div class="field">
				<input type="text" name="data[Search][startdate]" value="<?php echo  isset($jobsrc['startdate'])?$jobsrc['startdate']:"Start Date"; ?>" class="app_input date" style="width:200px;margin-right:5px" />
				<input type="text" name="data[Search][enddate]" value="<?php echo  isset($jobsrc['enddate'])?$jobsrc['enddate']:"End Date"; ?>" class="app_input date" style="width:200px;margin-right:5px" />
			</div>
			<div class="field">
				<input type="text" name="data[Search][str]" value="<?php echo  isset($jobsrc['str'])?$jobsrc['str']:""; ?>" class="app_input" style="width:200px" />
				<?php //echo App::Helper('Html')->selectTag("data[Search][field]",array(""=>"","title"=>"Title","created"=>"Created","start_date"=>"Start Date","end_date"=>"End Date"),(isset($jobsrc['field'])?$jobsrc['field']:"")) ?>
				<?php if(!$userId) echo App::Component('Photocliping')->Helper("Data")->memberListBox("data[Search][member]",(isset($jobsrc['member'])?$jobsrc['member']:"")); ?>


				<input type="submit"  name="data[Search][searchbtn]" value="Search" class="app_button" style="margin:2px;padding:6px;color:#FFF;border:1px solid #B3B3B3;background-color:#003871" />
			</div>
		</div>
		<?php
		if(!empty($Data['data']))
		{
			$o = ($o == 'DESC') ? 'ASC' : 'DESC';
			 App::Module('DataGrid')->clear()
				->setDisplay('TableListing')
				->setHeader(Array(
								  "<a href=\"?s=id&o={$o}\">#</a>",
								  "<a href=\"?s=title&o={$o}\">Title</a>",
								  //"Name",
								  "Email",
								  "<a href=\"?s=num_images&o={$o}\">Imgs</a>",
								  "<a href=\"?s=total&o={$o}\">$$$</a>",
								  "<a href=\"?s=created&o={$o}\">Created</a>",
								 // "<a href=\"?s=start_date&o={$o}\">Start&nbsp;Date</a>",
								  "<a href=\"?s=end_date&o={$o}\">ED</a>",
								  "<a href=\"?s=status&o={$o}\">Status</a>",
								  "%",
								  "DT",
								  "<a href=\"?s=paymentstatus&o={$o}\">Payment</a>",
								  ""))
				->setFooter($Data['paging_str']);
                                 
				foreach($Data['data'] as $Job)
				{ //pr($Job['delivery_time']);
					$EndDateData = App::Component('Photocliping')->helper('Data')->calculateEndDate($Job);
                    //pr($EndDateData);
					$member = App::MemberManager()->Members($Job['client_id']);
					$color = '#FFFFFF';
					$sp = '-';
					$enddate = "-";
					if(!empty($EndDateData))
					{
						$enddate = $EndDateData['enddate'];
						$color = $EndDateData['legend'][0];
						$sp = "{$EndDateData['legend'][1]}";
					}

					 App::Module('DataGrid')->setTagOptions(array("style"=>"background-color:{$color}"))->addRow
					 ($Job['id'],
					  App::load("Helper/Html")->linkTag($this->baseurl('/pcjobs/manage/view/' . $Job['id'] ),$Job['title']),
					  //(isset($member['name'])?$member['name']:""),
					  (isset($member['email'])?$member['email']:""),
					  $Job['num_images'],
					  $Job['total'],
					  App::Load("Helper/Date")->dateFormated($Job['created']),
					 // (($Job['start_date']!="")?App::Load("Helper/Date")->dateFormated($Job['start_date'],'long'):"-"),
					  $enddate,
					  App::Component('Photocliping')->Helper("Data")->displayStatus($Job['status']),
					  $sp,
					  App::CategorySet()->idToName($Job['delivery_time']),
					  App::Component('Photocliping')->Helper("Data")->paymentStatus($Job['paymentstatus']),
					  App::load("Helper/Html")->linkTag($this->baseurl('/pcjobs/manage/view/' . $Job['id'] ),App::load("Helper/Html")->imgTag($this->baseurl('/images/admin/view.gif'),array('title' => 'View ',NULL,'alt'=>'View',"class"=>"icon"))) .
					  App::Component('Photocliping')->Helper("Data")->displayStatusLink($Job) . 
                     App::load("Helper/Html")->linkTag("javascript:void(0)",App::load("Helper/Html")->imgTag($this->baseurl('/images/admin/remove.gif'),NULL,array('title'=>'Delete','alt'=>'Delete')),array('id'=>'Job','class'=>'link_delete icon', 'title'=>'Job_' . $Job['id']))
					  );
				}
				App::Module('DataGrid')->Render();
			}
			else
			{
				echo "<p>No data found</p>";
			}
		?>
	<?php endif ?>
	<?php if(App::getUserStatusId()):?>
		<?php App::Helper('Toolbar')->setBtnBack()->Render(array('code'=>'pcjob_bottom_top')); ?>
	<?php else:?>
		<?php App::Helper('Toolbar')->setBtnBack()->setBtnSave(array("name"=>"Update"))->Render(array('code'=>'pcjob_bottom_top')); ?>
	<?php endif;?>
<?php endif;?>
</form>